<template>
  <div class="app-container">
    <!-- 查询 -->
    <tl-list-search ref="search" :query-param="queryParam" @search="doQuery" :isDisplayDefaultSearch="false" v-if="isHeaderDisplay">
      <template slot="search">
        <el-form-item label="产品名称">
          <el-input v-model="queryParam.qry_name" placeholder></el-input>
        </el-form-item>
        <el-form-item label="所属产品线">
          <el-select v-model="queryParam.qry_productline" clearable filterable>
            <el-option v-for="item in product_lineList" :key="item.code" :label="item.name" :value="item.code" clearable />
          </el-select>
        </el-form-item>
        <el-form-item label="产品类别1">
          <el-select v-model="queryParam.qry_catelog1" clearable filterable>
            <el-option v-for="item in catalog1List" :key="item.code" :label="item.name" :value="item.code" clearable />
          </el-select>
        </el-form-item>
        <el-form-item label="产品类别2">
          <el-select v-model="queryParam.qry_catelog2" clearable filterable>
            <el-option v-for="item in catalog2List" :key="item.code" :label="item.name" :value="item.code" clearable />
          </el-select>
        </el-form-item>
        <el-form-item label="产品小类">
          <el-select v-model="queryParam.qry_catelog3" clearable filterable>
            <el-option v-for="item in catalog3List" :key="item.code" :label="item.name" :value="item.code" clearable />
          </el-select>
        </el-form-item>
        <el-form-item label="行销分类">
          <el-select v-model="queryParam.qry_marketingclassification" clearable filterable>
            <el-option v-for="item in marketingclassificationList" :key="item.code" :label="item.name" :value="item.code" clearable />
          </el-select>
        </el-form-item>
				<el-form-item label="是否发布">
					<el-select v-model="queryParam.qry_publishstate" clearable filterable>
						<el-option v-for="item in enabledList" :key="item.code" :label="item.name" :value="item.code" clearable />
					</el-select>
				</el-form-item>
        <el-form-item label="是否启用">
					<el-select v-model="queryParam.qry_enabled" clearable filterable>
						<el-option v-for="item in enabledList" :key="item.code" :label="item.name" :value="item.code" clearable />
					</el-select>
				</el-form-item>
      </template>
    </tl-list-search>
    <!-- 工具栏 -->
    <tl-list-toolbar ref="toolbar" @add="openAddDialog('editForm')" @exportExcel="doExportExcel" @deleteBatch="doDeleteBatch" @refresh="doRefresh" @columnCustomize="doColumnCustomize" @displaySearch="doDisplaySearch" :disableDeleteBatch="selectedRowKeys.length <= 0" :isDisplayDeleteBatch="false" :isDisplayExport="false">
      <template slot="left-btn"> </template>
    </tl-list-toolbar>
    <div>
      <!-- 列表选择 -->
      <div class="table-alert-div" ref="selector">
        <el-alert type="success" :closable="false" class="tl-table-alert-info" effect="light">
          <template slot="title">
            已选择&nbsp;<a class="tl-table-alert-info-a1">{{ selectedRowKeys.length }}</a
            >项&nbsp;&nbsp;
            <a class="tl-table-alert-info-a2" @click="doClearSelected">全部清空</a>
          </template>
        </el-alert>
      </div>
      <!--表格渲染-->
      <el-table class="tl-table" ref="mainTable" :height="tableHeight" resizable-key="tableHeight" :resizable-refs="tableResizeRefs" v-loading="loading" :data="datas" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" @row-click="doRowClick" row-key="id" border fit :row-class-name="doChangeRowClassName">
        <el-table-column type="index" label="序号" width="55px" align="center"></el-table-column>
				<el-table-column prop="name" label="产品名称" width="200px" sortable="custom" sort-by="name" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column prop="dispproductline" label="所属产品线" width="150px" sortable="custom" sort-by="productline" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column prop="dispcatalog1" label="类别1" width="150px" sortable="custom" sort-by="catalog1" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column prop="dispcatalog2" label="类别2" width="150px" sortable="custom" sort-by="catalog2" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column prop="deptcodearrayname" label="相关部门"  width="300px" sortable="custom" sort-by="deptcodearrayname" align="left" header-align="left" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="dispmarketingclassification" label="行销分类" sortable="custom" sort-by="marketingclassification" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column prop="description" label="备注" min-width="50px" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column prop="enabled" label="是否发布" width="75px" sortable="custom" sort-by="enabled" align="center" header-align="center">
					<template slot-scope="scope">
						<el-tag v-if="scope.row.publishstate === '1'" type="success">是</el-tag>
						<el-tag v-else type="danger">否</el-tag>
					</template>
				</el-table-column>
				<el-table-column prop="enabled" label="启用" width="55px" sortable="custom" sort-by="enabled" align="center" header-align="center">
					<template slot-scope="scope">
						<el-tag v-if="scope.row.enabled === 1" type="success">是</el-tag>
						<el-tag v-else type="danger">否</el-tag>
					</template>
				</el-table-column>
        <el-table-column label="操作" width="80px" align="center" v-slot="scope" fixed="right">
          <el-dropdown trigger="hover">
            <el-button type="text" icon="el-icon-s-operation">操作<i class="el-icon-arrow-down el-icon--center"></i></el-button>
            <el-dropdown-menu>
              <el-dropdown-item type="text" icon="el-icon-view" @click.native="openViewDialog('editForm', scope.row.id)">查看</el-dropdown-item>
              <el-dropdown-item type="text" icon="el-icon-edit" @click.native="openEditDialog('editForm', scope.row.id)">编辑</el-dropdown-item>
              <el-dropdown-item type="text" icon="el-icon-delete" @click.native="doDelete(scope.row.id)">删除</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-table-column>
      </el-table>
      <!-- 列表分页 -->
      <el-row class="pagebar" ref="pager">
        <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
      </el-row>
      <tl-edit ref="editForm" @refresh="doRefresh"></tl-edit>
    </div>
  </div>
</template>

<script>
/** mixins */
import { mixin_list } from '@tapui/mixins/mixin_list'
/** 子组件 */
import tlEdit from './edit'
/** 工具类 */
import { getAction, putAction, postAction, deleteAction } from '@tapui/utils/http'
export default {
  name: 'mmsProductBaseInfo',
  mixins: [mixin_list],
  components: { tlEdit },
  data() {
    return {
      description: '产品基础信息表新-列表查询',
      urlPrefix: '/mms/productBaseInfo/',
      url: {
        queryCodeList: '/mms/productBaseInfo/dataCodeList'
      },
      // 排序参数
      sorterInfo: {
        sidx: "nlssort(name,'NLS_SORT=SCHINESE_PINYIN_M'),nlssort(catalog1,'NLS_SORT=SCHINESE_PINYIN_M'),nlssort(catalog2,'NLS_SORT=SCHINESE_PINYIN_M')",
        sord: 'asc'
      },
      catalog1List: [],
      catalog2List: [],
      catalog3List: [],
      product_lineList: [],
      marketingclassificationList: [],
			enabledList: []
    }
  },
  methods: {
    queryDataCodeList(parameter) {
      getAction(this.url.queryCodeList, parameter).then((res) => {
        if (res.success) {
          this.catalog1List = res.result.catalog1List
          this.catalog2List = res.result.catalog2List
          this.catalog3List = res.result.catalog3List
          this.product_lineList = res.result.productlineList
          this.marketingclassificationList = res.result.marketingclassificationList
          this.enabledList = res.result.enabledList
        } else {
          this.$tap.alert(res.message)
        }
      })
    }
  },
  mounted() {
    this.queryDataCodeList({})
  }
}
</script>

<style scoped></style>

